from tkinter import *
import socket
b=[]
root = Tk()  # 创建窗口对象的背景色
while (str!="root.123"):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(('127.0.0.1', 8001))
    str = input("请输入要传入的字符")
    b.append(str)
 # 将小部件放置到主窗口中
    s.sendall(str.encode())
    data = s.recv(1024)
    print(data.decode())
    s.close()

listb = Listbox(root)
for item in b:
    listb.insert(0,item)
listb.pack()
root.mainloop()